﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="CustomerSample.Window1"
    Title="CustomerSample" Height="300" Width="300"
		xmlns:l="clr-namespace:CustomerSample;assembly=CustomerSample"
		xmlns:v="http://www.codeplex.com/entlibcontrib"
    >
	<Window.Resources>
		<Style x:Key="validationStyle" TargetType="{x:Type TextBox}">
			<Style.Triggers>
				<Trigger Property="Validation.HasError" Value="True">
					<Setter
								 Property="ToolTip"
								 Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
				</Trigger>
			</Style.Triggers>
		</Style>		 
	 </Window.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<Label Content="First Name:"/>
		<TextBox Grid.Column="1" Text="{v:ValidationBinding FirstName}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="Last Name:" Grid.Row="1"/>
		<TextBox Grid.Column="1" Grid.Row="1" Text="{v:ValidationBinding LastName}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="Nickname:" Grid.Row="2"/>
		<TextBox Grid.Column="1" Grid.Row="2" Text="{v:ValidationBinding Nickname}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="Birth date:" Grid.Row="3"/>
		<TextBox Grid.Column="1" Grid.Row="3" Text="{v:ValidationBinding BirthDate}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="Street:" Grid.Row="4"/>
		<TextBox Grid.Column="1" Grid.Row="4" Text="{v:ValidationBinding Address.Street}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="Number:" Grid.Row="5"/>
		<TextBox Grid.Column="1" Grid.Row="5" Text="{v:ValidationBinding Address.Number}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Label Content="State:" Grid.Row="6"/>
		<TextBox Grid.Column="1" Grid.Row="6" Text="{v:ValidationBinding Address.USState}" TextWrapping="Wrap" Style="{StaticResource validationStyle}"/>
		<Button Click="OnValidate" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Validate" Grid.Row="7" Grid.RowSpan="2"/>
	</Grid>
</Window>
